Game rắn săn mồi bằng c# _ snake full code
16.766 lượt xem;
- Input.cs
- project /
1 using System.Collections;
2 using System.Windows.Forms;
3
4 namespace Snake
5 {
6 internal class Input
7 {
8 //Load list of available Keyboard buttons
9 private static Hashtable keyTable = new Hashtable();
10
11 //Perform a check to see if a particular button is pressed.
12 public static bool KeyPressed(Keys key)
13 {
14 if (keyTable[key] == null)
15 {
16 return false;
17 }
18
19 return (bool) keyTable[key];
20 }
21
22 //Detect if a keyboard button is pressed
23 public static void ChangeState(Keys key, bool state)
24 {
25 keyTable[key] = state;
26 }
27 }
28 }
2 using System.Windows.Forms;
3
4 namespace Snake
5 {
6 internal class Input
7 {
8 //Load list of available Keyboard buttons
9 private static Hashtable keyTable = new Hashtable();
10
11 //Perform a check to see if a particular button is pressed.
12 public static bool KeyPressed(Keys key)
13 {
14 if (keyTable[key] == null)
15 {
16 return false;
17 }
18
19 return (bool) keyTable[key];
20 }
21
22 //Detect if a keyboard button is pressed
23 public static void ChangeState(Keys key, bool state)
24 {
25 keyTable[key] = state;
26 }
27 }
28 }